Skip to content

feat(nuxt)!: Bundle server config into Nitro build - #24094

Open
s1gr1d wants to merge 15 commits into
developfrom
sig/nuxt-server-config-auto-add
Open

feat(nuxt)!: Bundle server config into Nitro build#24094
s1gr1d wants to merge 15 commits into
developfrom
sig/nuxt-server-config-auto-add

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Sep 4, 2026

Copy link
Copy Markdown
Member

Previously, the sentry.server.config.ts file was emitted in the build output so it can be added with --import. As we don't rely on early-importing anymore (thanks to orchestrion), we don't need this file anymore.

  • Nitro plugin init (default): The server config is now bundled into the Nitro build and imported by a generated nitro plugin, so Sentry.init runs at startup without node --import. Works on Nitro 2 and 3, prod and dev (hurray)
  • --import compat: The old file path now gets a shim that just prints "remove this flag". A CI variant runs the whole suite with the shim preloaded to see if the warning is printed
  • Double init guard: A preload that really calls init wins. The bundled init skips with a notice.
  • Prerender: Init is skipped during prerendering, so CI builds send nothing. Tests assert no trace meta tags in prerendered HTML.
  • Early-crash tests: Errors thrown before listen are captured and flushed (first and last plugin slot)
  • Deprecated: both autoInjectServerSentry modes, kept working until v12

Closes #24149

@s1gr1d
s1gr1d requested a review from a team as a code owner September 4, 2026 13:11
@s1gr1d
s1gr1d requested review from chargome and mydea and removed request for a team September 4, 2026 13:11
@s1gr1d

s1gr1d commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.8 kB - -
@sentry/browser - with treeshaking flags 27.11 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27 kB - -
@sentry/browser (incl. Tracing) 49.22 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 49.22 kB - -
@sentry/browser (incl. Tracing, Profiling) 52.12 kB - -
@sentry/browser (incl. Tracing, Replay) 88.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.95 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 93.44 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 106.37 kB - -
@sentry/browser (incl. Feedback) 46.3 kB - -
@sentry/browser (incl. sendFeedback) 33.86 kB - -
@sentry/browser (incl. FeedbackAsync) 38.97 kB - -
@sentry/browser (incl. Metrics) 29.82 kB - -
@sentry/browser (incl. Logs) 30.09 kB - -
@sentry/browser (incl. Metrics & Logs) 30.75 kB - -
@sentry/react 30.55 kB - -
@sentry/react (incl. Tracing) 51.56 kB - -
@sentry/vue 36.05 kB - -
@sentry/vue (incl. Tracing) 51.48 kB - -
@sentry/svelte 28.83 kB - -
CDN Bundle 30.55 kB - -
CDN Bundle (incl. Tracing) 49.74 kB - -
CDN Bundle (incl. Logs, Metrics) 32.82 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.7 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.48 kB - -
CDN Bundle (incl. Tracing, Replay) 87.29 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 89.18 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 93.22 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 95.21 kB - -
CDN Bundle - uncompressed 90.46 kB - -
CDN Bundle (incl. Tracing) - uncompressed 148.17 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.03 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 154.14 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.29 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.76 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.71 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 287.4 kB - -
@sentry/nextjs (client) 54.03 kB - -
@sentry/sveltekit (client) 49.65 kB - -
@sentry/core/server 36.99 kB - -
@sentry/core/browser 13.55 kB - -
@sentry/node 127.63 kB +0.02% +20 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.58 kB - -
@sentry/node - without tracing 88.71 kB +0.03% +21 B 🔺
@sentry/node - without channel injection 106.9 kB +0.02% +18 B 🔺
@sentry/aws-serverless 97.09 kB +0.03% +24 B 🔺
@sentry/cloudflare (withSentry) - minified 201.95 kB - -
@sentry/cloudflare (withSentry) 502.67 kB - -

View base workflow run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 830a18a. Configure here.

Comment thread packages/nuxt/src/vite/addServerConfig.ts

@chargome chargome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions and nits, otherwise this looks good overall!

consoleSandbox(() => {
// eslint-disable-next-line no-console
console.log(
'[Sentry] The Sentry server SDK is already initialized, skipping a second initialization. The Sentry server config is bundled into the Nitro server build, so a `node --import` preload of the config file is no longer needed and can be removed.',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: Does this correctly work in dev-mode? Just want to double check that we are not spamming the console there

// Dev relies on runtime injection (no build-time transform), but the dev bundle hoists the ioredis
// import above the inlined `Sentry.init`, so its instrumented file loads before injection is active
// and gets no channels (5.10.x has no native ones). mysql requires its file lazily, after init.
test.skip(process.env.TEST_ENV === 'development', 'ioredis loads before runtime injection is active in dev');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: With native channels this does work right? so >5.10.x?

@@ -6,6 +6,11 @@ import { waitForTransaction } from '@sentry-internal/test-utils';
// only happens in the production build, so these tests are excluded from the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: Stale comment with this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nuxt: Bundle server config into build

2 participants